import axios from '@/utils/request';

/**
 * 一级分类
 * @param params 查询条件
 */
export async function list(params) {

  const res = await axios.get('/figure.video/index', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function errorVideo(params) {

  const res = await axios.get('/figure.video/errorVideo', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加
 * @param data 机构信息
 */
export async function add(data) {
  const res = await axios.post('/figure.video/add', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 修改
 * @param data 机构信息
 */
export async function update(data) {
  const res = await axios.post('/figure.video/edit', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 排序
 * @param params nid oid 两个排序的id
 */
 export async function sortChange(params) {
  const res = await axios.post('/figure.video/sortChange', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 排序
 * @param params nid oid 两个排序的id
 */
 export async function modify(data) {
  const res = await axios.post('/figure.video/modify', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除
 * @param id id
 */
export async function remove(id) {
  const res = await axios.get('/figure.video/delete?id=' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


export async function changeStatus(data) {
  const res = await axios.post('/figure.video/change', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function resubmit(data) {
  const res = await axios.post('/figure.video/resubmit', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function oss_transfer(data) {
  const res = await axios.post('/figure.video/oss_transfer', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


export async function refund(id) {
  const res = await axios.get('/figure.video/refund?id=' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


export async function more(id) {
  const res = await axios.get('/figure.video/videoInfo?id=' + id);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data));
}

export async function independenceVideo(params) {

    const res = await axios.get('/figure.video/independenceVideo', {
        params
    });
    if (res.data.code === 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}